/**
 * 订单管理 交易订单
 */
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>受助者详细情况</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true"  class="user-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="searchname" placeholder="输入受助者姓名"></el-input>
      </el-form-item>
     <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-form-item>
    
    </el-form>
    <!--列表-->
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" type="index" width="60">
      </el-table-column>
      <el-table-column sortable prop="id" label="受助人ID" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="userName" label="用户名" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="realName" label="受助者姓名" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="sex" label="性别" show-overflow-tooltip>
      </el-table-column>
      <!-- <el-table-column sortable prop="account" label="账户" width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="phone" label="电话号码" width="180" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="email" label="邮箱" width="140" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="address" label="地址" width="120" show-overflow-tooltip>
      </el-table-column>
      <el-table-column sortable prop="difficultyType" label="困难类型" width="120" show-overflow-tooltip>
      </el-table-column> -->
      <el-table-column sortable prop="createDate" label="注册时间"  show-overflow-tooltip>
        <template slot-scope="scope">
          <div>{{scope.row.createDate|timestampToTime}}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" >
        <template slot-scope="{row}">
          <el-button size="mini" type="primary" @click="edit( row)">查看详细</el-button>
         
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
    <!-- 添加 -->
    <el-dialog title="捐助单" :visible.sync="editFormVisible" width="50%" >
      <el-form label-width="120px" :model="newlist" ref="newlist">
        <el-row>
          <el-col :span="12">
            <el-form-item label="受助人ID">
              <el-input size="small" v-model="newlist.id" auto-complete="off" placeholder="请输入捐助人ID" disabled></el-input>
            </el-form-item>
            <el-form-item label="用户名">
              <el-input size="small" v-model="newlist.userName" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
          <el-form-item label="受助者姓名">
              <el-input size="small" v-model="newlist.realName" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
          <el-form-item label="性别">
              <el-input size="small" v-model="newlist.sex" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
          <el-form-item label="账户">
              <el-input size="small" v-model="newlist.account" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
           <el-form-item label="电话号码">
              <el-input size="small" v-model="newlist.phone" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
           <el-form-item label="邮箱">
              <el-input size="small" v-model="newlist.email" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
           <el-form-item label="地址">
              <el-input size="small" v-model="newlist.address" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
          <el-form-item label="困难类型">
              <el-input size="small" v-model="newlist.difficultyType" auto-complete="off" placeholder="" disabled></el-input>
          </el-form-item>
          </el-col>
        </el-row>
      </el-form>
        <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">关闭</el-button>
   
      </div>
    </el-dialog>

    <!-- 随机捐款弹框 -->

  </div>
</template>

<script>
import axios from 'axios';
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {  
      searchname:'',
      newlist:{},
      newlist1:{},

      dialogStatus:"",
      loading: false, //是显示加载
      editFormVisible1: false, //控制编辑页面显示与隐藏

      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '预览',
      payType: [
        { key: '请选择', value: 0 },
        { key: '通过', value: '通过' },
        { key: '不通过', value: '不通过' }
      ],
     
      editForm: {
        id: '',
        userName: '',
        password: '',
        role: '',
        realName: '',
        sex: '',
        idCard: '',
        account: '',
        phone: '',
        email: '',
        address: '',
        difficultyType: '',
        createDate: '',
        token: localStorage.getItem('logintoken')
      },
      formInline: {
        page: 1,
        limit: 10,
        machineNo: '',
        orderNo: '',
        transId: '',
        payType: 0,
        orderStatus: 0,
        // token: localStorage.getItem('logintoken')
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  /**
   * 数据发生改变
   */

  /**
   * 创建完毕
   */
  created() {
    this.getdata()
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
 
    // 获取公司列表
   getdata() {
      this.loading = false
      axios.get("http://47.106.193.50:8080/userBySZ").then(res => {
        
            let data = res.data.data
            this.listData = data
            // 分页赋值
            // this.pageparm.currentPage = this.formInline.page
            // this.pageparm.pageSize = this.formInline.limit
            // this.pageparm.total = res.count
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getdata(this.formInline)
    },
    // 搜索事件
         search() {
        let arr= []
        let list =  this.listData
       console.log(list,'323232');
       if (this.searchname == "") {
           this.getdata()
       }else{
        // console.log(this.searchname);
        for (let i = 0; i < list.length; i++) {
         if (list[i].realName.indexOf(this.searchname) >= 0) {
         arr.push(list[i])
      }}
        //  console.log(arr,'react');
         this.listData = arr
       }},
    //显示编辑界面
   
  

    //修改更新
   async edit(row) {
      this.newlist = { ...row };
      this.editFormVisible = true;
      console.log(this.newlist, "edit 信息");
      this.title = "修改"
      this.dialogStatus = "edit";
      console.log(this.dialogStatus,'修改');

    },
   

   
  
    // 删除

    handleDelete(row) {
      var data = row._id
    
      console.log(data);
      axios.post("",data).then((response) => {
        console.log(response);
        if (response.data.code == "200") {
      
          this.getdata()
          this.$notify({
            
            title: "删除成功",
            message: "delete Successfully",
            type: "success",
            duration: 2000,
          });
        } else {
          this.$notify({
            title: "删除失败",
            message: "delete failly",
            type: "warning",
            duration: 2000,
          });
        }
        this.getdata()
      });
    },
    // 关闭编辑、增加弹出框
       closeDialog1() {
      this.editFormVisible1 = false
  
    },
    closeDialog() {
      this.editFormVisible = false
    
    }
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 
 

 